{extend name="common/common" /}

{block name="content"}
	<div class="ibox-title">
	    <h5>电子商务进农村综合示范进展情况列表</h5>
	</div>
	<div class="ibox-content">
		<div id="table-box">
			<el-form :inline="true" class="search-table-form">
				<el-form-item>
					<el-select v-model="sea.seaDepart" placeholder="请选择地区">
						{volist name="departs" id="v"}
						<el-option label="{$v.name}" value="{$v.id}"></el-option>
						{/volist}
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-date-picker
						v-model="sea.seaTime[0]"
						type="date"
						value-format="timestamp"
						placeholder="开始时间">
					</el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-date-picker
						v-model="sea.seaTime[1]"
						type="date"
						value-format="timestamp"
						placeholder="结束时间">
					</el-date-picker>
				</el-form-item>
				<el-form-item>
					<el-input
						placeholder="请输入填报人"
						clearable="true"
						v-model="sea.seaLinkman">
					</el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="info" plain @click="getTable">查询</el-button>
				</el-form-item>
			</el-form>
			<el-table :data="tableData" stripe="true" border>
				<el-table-column align="center" prop="id" sortable width="80"
					label="序号">
				</el-table-column>
				<el-table-column align="center" prop="depart_name" label="填报单位"></el-table-column>
				<el-table-column align="center" prop="rpt_date" sortable
					label="报表日期">
				</el-table-column>
				<el-table-column align="center" prop="link_man" label="填报人"></el-table-column>
				<el-table-column align="center" prop="link_type" label="联系电话"></el-table-column>
				<el-table-column align="center" prop="is_commit" label="是否提交">
					<template slot-scope="scope">
						<el-tag
							:type="scope.row.is_commit == '1' ? 'warning' : 'info'">
							{{ scope.row.is_commit == 1?'已提交':'未提交' }}
						</el-tag>
					</template>
				</el-table-column>
				<el-table-column align="center" prop="examine_name" label="是否通过">
					<template slot-scope="scope">
						<el-tag
							:type="scope.row.examine_name == '是' ? 'primary' : 'info'">
							{{ scope.row.examine_name }}
						</el-tag>
					</template>
				</el-table-column>
				<el-table-column align="center" prop="examine_man" label="审核人"></el-table-column>
				<el-table-column align="center" prop="examine_remark" label="审核意见"></el-table-column>
				<el-table-column align="center" prop="operate" label="操作" width="250">
					<template slot-scope="scope">
						{if authCheck('tablequery/daysee')}
						<el-tooltip content="查看" open-delay="500" hide-after="1500" placement="bottom">
						<el-button circle
							@click="seeRow(scope.row)"
							size="mini" plain 	type="info"
							icon="fa fa-eye">
						</el-button>
						</el-tooltip>
						{/if}
						{if authCheck('tablequery/dayedit')}
						<el-tooltip content="编辑" open-delay="500" hide-after="1500" placement="bottom">
						<el-button circle
							@click="editRow(scope.row)"
							size="mini" plain type="success"
							icon="el-icon-edit">
						</el-button>
						</el-tooltip>
						{/if}
						{if authCheck('tablequery/daydel')}
						<el-tooltip content="删除" open-delay="500" hide-after="1500" placement="bottom">
						<el-button circle
							@click="delRow(scope.row)"
							size="mini" plain 	type="danger"
							icon="el-icon-delete">
						</el-button>
						</el-tooltip>
						{/if}
						{if authCheck('tablequery/dayexamine')}
						<el-tooltip content="审核" open-delay="500" hide-after="1500" placement="bottom">
						<el-button circle
							@click="examineRow(scope.row)"
							size="mini" plain 	type="primary"
							icon="el-icon-success">
						</el-button>
						</el-tooltip>
						{/if}
						<el-tooltip content="提交" open-delay="500" hide-after="1500" placement="bottom">
						<el-button circle
							@click="commitRow(scope.row)"
							size="mini" plain 	type="warning"
							icon="el-icon-upload2">
						</el-button>
						</el-tooltip>
					</template>
				</el-table-column>
			</el-table>
			<div class="table-page">
				<el-pagination
					@size-change="pageSizeChange"
					@current-change="curPageChange"
					:current-page="sea.pageNumber"
					:page-sizes="[10, 20, 50, 75]"
					:page-size="sea.pageSize"
					layout="total, sizes, prev, pager, next, jumper"
					:total="tableTotal">
				</el-pagination>
			</div>
		</div>
	</div>
{/block}

{block name="component"}
<div id="exBox">
<el-dialog title="审核报表" :visible.sync="is_show" tool="15vh">
	<el-form :model="form">
		<el-form-item label="是否通过">
			<el-radio-group v-model="form.is_examine" size="mini">
				<el-radio-button :label="1">是</el-radio-button>
				<el-radio-button :label="0">否</el-radio-button>
			</el-radio-group>
		</el-form-item>
		<el-form-item label="审核意见">
			<el-input type="textarea" v-model="form.examine_remark" placeholder="审批审核意见"></el-input>
		</el-form-item>
	</el-form>
	<div slot="footer" class="dialog-footer">
		<el-button @click="is_show = false">取消</el-button>
		<el-button type="success" @click="subForm">确定</el-button>
	</div>
</el-dialog>
</div>
<script type="text/javascript">
var exBox = new Vue({
	el:"#exBox",
	data:{
		is_show:false,
		form:{
			id:0,
			is_examine:0,
			examine_remark:''
		}
	},
	methods:{
		subForm(){
			var param = this.form;
			$.post('{:url("Tablequery/dayExamine")}',param,function(res){
				if(res.code == 1){
					exBox.is_show = false;
					main.$notify({title:"成功",type:"success",message:res.msg});
					main.getTable();
				}else{
					main.$notify.error({title:"错误",message:res.msg})
				}
			})
		}
	}
})
</script>
{/block}

{block name="script"}
<script type="text/javascript">
var main =  new Vue({
	el:"#main",
	data() {
		return {
			loading:false,
			sea:{
				seaDepart:"",
				seaTime:{0:"",1:""},
				seaLinkman:"",
				pageSize:10,
				pageNumber:1
			},
			tableData:'',
			tableTotal:0
		}
	},
	mounted:function(){
		this.getTable();
	},
	methods:{
		getTable(){
			this.loading=true;
			var param = this.sea;
			$.post('./Day',param,function(res){
				main.loading=false;
				if(res.code == 1){
					main.$message({message: res.msg,type: 'success'});
					main.tableData = res.data.rows;
					main.tableTotal = res.data.total;
				}else{
					main.$notify.error({title: '失败',message: res.msg,});
				}
			})
		},
		pageSizeChange(val) {
			this.sea.pageSize = val;
			this.getTable();
		},
		curPageChange(val) {
			this.sea.pageNumber = val;
			this.getTable();
		},
		editRow(row){
			window.location.href = "{:url('Tablequery/dayEdit')}?id="+row.id;
		},
		delRow(row){
			this.$confirm('此操作将永久删除该报表, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				$.post('./dayDel',{
					'id':row.id
				},function(res){
					if(res.code == '1'){
						main.$notify({title:"成功",type:"success",message:res.msg});
						main.getTable();
					}else{
						main.$notify.error({title:"错误",message:res.msg})
					}
				})
			}).catch(() => {
				this.$notify.info({title: '消息',message: '已取消删除'});
			});
		},
		examineRow (row){
			exBox.is_show = true;
			exBox.form.id = row.id;
			exBox.form.examine_remark = row.examine_remark;
			exBox.form.is_examine = row.is_examine;
		},
		seeRow(row) {
			window.location.href = "{:url('Tablequery/daySee')}?id="+row.id;
		},
		commitRow(row) {
			this.$confirm('此操作将提交该报表, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				$.post('{:url("Commit/CommitDay")}',{
					table_id:row.id
				},function(res) {
					if(res.code == 1){
						main.$notify({title:"成功",type:"success",message:res.msg});
						main.getTable();
					}else{
						main.$notify.error({title:"错误",message:res.msg});
					}
				});
			}).catch(() => {
				this.$notify.info({title: '消息',message: '已取消提交'});
			});
		}
	}
})
</script>
{/block}
